Skip to content

[FEATURE] add envelope slope, inharmonicity and phase plane plots to pytta.response - #112

Open
aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-response_more
Open

aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-response_more

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds to pytta.response the three measures of #33 that #74 does not cover:

  1. envelope_slope(signalObj, top=-5, bottom=-35): the slope, in dB per second, of the Hilbert envelope of a decaying transient, fitted between top and bottom dB below its maximum. q_from_decay now uses it, with the same result.
  2. inharmonicity(signalObj, f0, numPartials=10): the inharmonicity coefficient B of the stiff string model f_n = n f0 √(1 + B n²) (Fletcher, "Normal vibration frequencies of a stiff piano string", J. Acoust. Soc. Am. 36, 203, 1964). Each partial is the interpolated spectral peak within f0 / 4 of where the partials found so far predict it, and f0 and B are fitted by least squares on f_n² / n² = f0² + f0² B n². It also returns the partials and their deviation from n f0 in cents.
  3. plot_phase_plane(signalObj, quantity='position'): position against velocity, velocity against acceleration and acceleration against position, the other two quantities derived from the given one in the frequency domain.

This pull request builds on #74 and shows its commits until #74 is merged.

The tests, added to tests/test_response.py, print the measured values:

  1. The envelope of exp(-t / τ) sin(ωt) falls by 20 log10(e) / τ dB per second (-173.72 dB/s for τ = 50 ms, within 0.1 %).
  2. Twelve partials of a string with B = 4e-4 at 110 Hz give B = 4.0000e-4 and f0 = 110.0000 Hz, the partials within 1.2e-5 Hz and the cents within 0.1 of the model.
  3. For x = cos(ωt) the plotted position and velocity lie on the ellipse x² + (v / ω)² = 1, from the position (1.7e-5) and from the acceleration (1.2e-8).

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

aguirreSL and others added 3 commits October 31, 2026 21:26
…trics

Resonance frequency and quality factor from the -3 dB bandwidth of the
magnitude response and from the decay of the envelope (Q = pi f0 tau),
-3 dB cutoff frequencies, passband ripple, and the rise time, overshoot
and settling time of a step response.

Tests use systems with exact values: second-order resonators of known Q
for both definitions, a Butterworth band-pass and a Chebyshev low-pass,
a first-order step (rise tau ln 9, settling tau ln 50) and second-order
steps (overshoot exp(-pi zeta / sqrt(1 - zeta^2))).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
response.bifurcation takes recordings along a sweep of a control
parameter, up and then down, measures the amplitude of the oscillation
in each (spectral peak near a given frequency, or rms), and returns the
onset going up, the extinction going down and the hysteresis between
them. The test uses a synthetic subcritical sweep with known thresholds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ytta.response

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
aguirreSL added a commit to aguirreSL/PyTTa that referenced this pull request Nov 1, 2026
…by hand

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant